
//-- H5语音朗读
function AudioPlayBystr(str_tip){
    var msg =new SpeechSynthesisUtterance();
    msg.rate = 0.8; //设置播放语速，范围：0.1 - 10之间
    msg.pitch = 1; //音调高低
    msg.text = str_tip;
    msg.volume = 50 ;//播放音量
    msg.lang="zh-CN";//语言类型
    speechSynthesis.speak(msg);//播放
    console.log(msg);
    msg.onstart=function(){console.log("开始播放会调用我")};
    msg.onend=function(){console.log("播放完成才会调用我")};
    msg.onpause=function(){console.log("播放暂停才会调用我")};
    msg.onresume=function(){console.log("播放重新开始才会调用我")};
    msg.onerror=function(error){console.log("播放出现错误才会调用我"+error)};
};

//-- 百度语音朗读
function audioPlay(text){
    var zhText = text;
    zhText = encodeURI(zhText);
    var audio = "<audio autoplay=\"autoplay\">" + "<source src=\"http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=4&per=0&text=" + zhText + "\" type=\"audio/mpeg\">" + "<embed height=\"0\" width=\"0\" src=\"http://tts.baidu.com/text2audio?text=" + zhText + "\">" + "</audio>";
    $('body').append(audio);
}